<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="类型：1-普通职位，2-灵活用工，3-共享用工" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="positionType">
              <j-dict-select-tag type="list" v-model="model.positionType" dictCode="position_type" placeholder="请选择类型：1-普通职位，2-灵活用工，3-共享用工" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否兼职：1-兼职，0-全职" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ifParttime">
              <j-dict-select-tag type="radio" v-model="model.ifParttime" dictCode="if_parttime" placeholder="请选择是否兼职：1-兼职，0-全职" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyId">
              <a-input v-model="model.companyId" placeholder="请输入公司ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="名称ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postId">
              <a-input v-model="model.postId" placeholder="请输入名称ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="职位名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postName">
              <a-input v-model="model.postName" placeholder="请输入职位名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="职位描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="descr">
              <a-textarea v-model="model.descr" rows="4" placeholder="请输入职位描述" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="地址名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="addressName">
              <a-input v-model="model.addressName" placeholder="请输入地址名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="门牌号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="addressHouse">
              <a-input v-model="model.addressHouse" placeholder="请输入门牌号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="工作地点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
              <a-input v-model="model.address" placeholder="请输入工作地点"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="地点经度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="longitude">
              <a-input v-model="model.longitude" placeholder="请输入地点经度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="地点纬度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="latitude">
              <a-input v-model="model.latitude" placeholder="请输入地点纬度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="经验要求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="expRequire">
              <a-input v-model="model.expRequire" placeholder="请输入经验要求"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="最低学历" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="minEducation">
              <j-dict-select-tag type="list" v-model="model.minEducation" dictCode="education" placeholder="请选择最低学历" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="薪资范围" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salaryLow">
              <a-input v-model="model.salaryLow" placeholder="请输入薪资范围"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="薪资范围" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salaryUp">
              <a-input v-model="model.salaryUp" placeholder="请输入薪资范围"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="薪资月份" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salaryMonth">
              <a-input-number v-model="model.salaryMonth" placeholder="请输入薪资月份" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="薪资范围" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salary">
              <a-input v-model="model.salary" placeholder="请输入薪资范围"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="薪资单位，兼职，元/时，元/天，元/周，元/月" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unit">
              <a-input v-model="model.unit" placeholder="请输入薪资单位，兼职，元/时，元/天，元/周，元/月"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="兼职，薪资单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unitMoney">
              <a-input-number v-model="model.unitMoney" placeholder="请输入兼职，薪资单价" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="奖金绩效" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bonus">
              <a-input v-model="model.bonus" placeholder="请输入奖金绩效"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="结算方式，兼职，日结、周结、月结、完工结" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="settlementType">
              <a-input-number v-model="model.settlementType" placeholder="请输入结算方式，兼职，日结、周结、月结、完工结" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="招聘人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recruitsNumber">
              <a-input-number v-model="model.recruitsNumber" placeholder="请输入招聘人数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="兼职工作日" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partDate">
              <a-input v-model="model.partDate" placeholder="请输入兼职工作日"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="兼职时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partTime">
              <a-input v-model="model.partTime" placeholder="请输入兼职时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone">
              <a-input v-model="model.phone" placeholder="请输入联系电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="技能要求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skill">
              <a-input v-model="model.skill" placeholder="请输入技能要求"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="开始日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="startDate">
              <j-date placeholder="请选择开始日期" v-model="model.startDate"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="结束日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="endDate">
              <j-date placeholder="请选择结束日期" v-model="model.endDate"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="工作天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workDays">
              <a-input-number v-model="model.workDays" placeholder="请输入工作天数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="共享人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shareNumber">
              <a-input-number v-model="model.shareNumber" placeholder="请输入共享人数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="分享佣金" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shareMoney">
              <a-input-number v-model="model.shareMoney" placeholder="请输入分享佣金" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="浏览数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="browseNumber">
              <a-input-number v-model="model.browseNumber" placeholder="请输入浏览数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <a-input v-model="model.remark" placeholder="请输入备注"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="县级城市名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="city">
              <a-input v-model="model.city" placeholder="请输入县级城市名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="县级城市编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="citycode">
              <a-input v-model="model.citycode" placeholder="请输入县级城市编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="市级城市名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pcity">
              <a-input v-model="model.pcity" placeholder="请输入市级城市名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="市级城市编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pcitycode">
              <a-input v-model="model.pcitycode" placeholder="请输入市级城市编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="tenantId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenantId">
              <a-input-number v-model="model.tenantId" placeholder="请输入tenantId" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="删除状态(0-正常,1-已删除)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag">
              <a-input-number v-model="model.delFlag" placeholder="请输入删除状态(0-正常,1-已删除)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
              <a-input v-model="model.status" placeholder="请输入状态"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'RmsCompanyPositionForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/rms/rmsCompanyPosition/add",
          edit: "/rms/rmsCompanyPosition/edit",
          queryById: "/rms/rmsCompanyPosition/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>